/**
 * 主题请求层
 * */

import { request } from 'umi';
import { getBaseUrl } from '@/services/urlconst';
import { getTenant } from '@/utils';

let baseUrl = getBaseUrl();

export async function getThemeList() {
  let url = `${baseUrl}/themeStyleController/getTheomeStyleList`;
  return request(url, {
    method: 'GET',
    toObj: false,
    headers: {
      tenantName: getTenant(),
    },
  });
}

/* 设置为默认主题 */
export async function isThemeDefault(params: any) {
  let url = `${baseUrl}/themeStyleController/isDefault`;
  return request(url, {
    method: 'PUT',
    toObj: false,
    headers: {
      tenantName: getTenant(),
    },
    data: {
      ...params,
    },
    requestType: 'json',
    charset: 'utf8',
    skipErrorHandler: true,
  });
}

/* 是否禁用 */
export async function isThemeOpen(params: any) {
  let url = `${baseUrl}/themeStyleController/isOpen`;
  return request(url, {
    method: 'PUT',
    toObj: false,
    headers: {
      tenantName: getTenant(),
    },
    data: {
      ...params,
    },
    requestType: 'json',
    charset: 'utf8',
    skipErrorHandler: true,
  });
}

/* 新增主题 */
export async function appendTheme(params: any) {
  let url = `${baseUrl}/themeStyleController/add`;
  return request(url, {
    method: 'POST',
    toObj: false,
    headers: {
      tenantName: getTenant(),
    },
    data: {
      ...params,
    },
    requestType: 'json',
    charset: 'utf8',
    skipErrorHandler: true,
  });
}

/* 编辑主题 */
export async function editTheme(params: any) {
  let url = `${baseUrl}/themeStyleController/edit`;
  return request(url, {
    method: 'PUT',
    toObj: false,
    headers: {
      tenantName: getTenant(),
    },
    data: {
      ...params,
    },
    requestType: 'json',
    charset: 'utf8',
    skipErrorHandler: true,
  });
}
